﻿/*
 *
 * Copyright 2007 by LongTop Corporation.
 * Softpack ChuangXin Building 15F, XiaMen, FuJian, PRC 361005
 *
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * LongTop Corporation ("Confidential Information").  You
 * shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement
 * you entered into with LongTop.
 *
 */

/**
 * 皮肤工具类。
 *
 * @author IntelliWeb Team
 * @version 2.o
 */

/**
 * 创建应用皮肤菜单
 * @param {HTMLElement} appObj 触发显示菜单对象
 */
function createApplicationSkinMenu(appObj) {
    //创建菜单
    var menu = new Menu();
    menu.init();
    appObj.menu = menu;

    //以下创建菜单项
    var menuItem;
    var menuItemNames = ["blue","green","red","sliver"];
    var menuItemLabels = ["蓝色皮肤","绿色皮肤","红色皮肤","银色皮肤"];
    var menuItemIcons = ["skin_blue.gif","skin_green.gif","skin_red.gif","skin_sliver.gif"];
    var skinPath = "/images/";

    for (var i = 0,_len = menuItemLabels.length; i < _len; i++) {
        menuItem = new MenuItem(menu, menu.rootItem);
        menuItem.setValue(menuItemNames[i]);
        menuItem.setLabel(menuItemLabels[i]);
        menuItem.setIcon(skinPath + menuItemIcons[i]);
        menuItem.onClickEvent = function(_menu, _menuItem) {
            SkinUtil.setSkin(_menuItem.getValue());
        }
    }
}

/**
 * 显示应用菜单
 */
function showApplicationSkinMenu(appObj) {
    if (!appObj.menu) {
        createApplicationSkinMenu(appObj);
    }

    //显示应用菜单
    appObj.menu.show(appObj);
    event.returnValue = false;
    event.cancelBubble = true;
}